<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
	<title>编辑文章</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		  content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all" />
	<script>
        var ctx = "${ctx}";
	</script>
	<style type="text/css">
		.layui-form-item .layui-inline {
			width: 33.333%;
			float: left;
			margin-right: 0;
		}

		@media ( max-width :1240px) {
			.layui-form-item .layui-inline {
				width: 100%;
				float: none;
			}
		}
	</style>
</head>
<body class="childrenBody">
<form class="layui-form" style="width: 80%;margin-top: 20px;">
	<input type="hidden" name="id" value="${cmsarticle.id}"/>

	<div class="layui-form-item">
		<label class="layui-form-label">栏目编号</label>
		<div class="layui-input-block">
			<input type="text" id="categoryId" class="layui-input userName"
				   lay-verify="required" placeholder="请输入栏目编号" name="categoryId" value="${cmsarticle.categoryId}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">标题</label>
		<div class="layui-input-block">
			<input type="text" id="title" class="layui-input userName"
				   lay-verify="required" placeholder="请输入标题" name="title" value="${cmsarticle.title}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">文章链接</label>
		<div class="layui-input-block">
			<input type="text" id="link" class="layui-input userName"
				    placeholder="请输入文章链接" name="link" value="${cmsarticle.link}">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">文章图片</label>
		<div class="layui-input-block">
			<input type="text" id="image" class="layui-input userName"
				    placeholder="请输入文章图片" name="image" value="${cmsarticle.image}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">关键字</label>
		<div class="layui-input-block">
			<input type="text" id="keywords" class="layui-input userName"
				    placeholder="请输入关键字" name="keywords" value="${cmsarticle.keywords}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">内容</label>
		<div class="layui-input-block">
			<textarea type="text" id="content" class="layui-input userName"  style="display: none"
					   placeholder="请输入内容" name="content" >${cmsarticle.content}</textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">来源</label>
		<div class="layui-input-block">
			<input type="text" id="copyfrom" class="layui-input userName"
				    placeholder="请输入来源" name="copyfrom" value="${cmsarticle.copyfrom}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">描述、摘要</label>
		<div class="layui-input-block">
			<input type="text" id="description" class="layui-input userName"
				   placeholder="请输入描述、摘要" name="description" value="${cmsarticle.description}">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">备注信息</label>
		<div class="layui-input-block">
			<input type="text" id="remarks" class="layui-input userName"
				    placeholder="请输入备注信息" name="remarks" value="${cmsarticle.remarks}">
		</div>
	</div>


	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn site-layedit" data-type="content" lay-submit="" lay-filter="editCmsArticle">立即提交</button>
		</div>
	</div>
</form>
<script type="text/javascript" src="${ctx}/layui/layui.js"></script>
<script type="text/javascript" src="${ctx}/page/cmsarticle/editcmsarticle.js"></script>
<script>
    layui.use('layedit', function(){
        var layedit = layui.layedit
            ,$ = layui.jquery;

		//设置图片上传接口
        layedit.set({
            uploadImage: {
                url: ctx+'/upload/uploadPic' //上传接口url
                ,type: 'POST' //默认post
            }
        });
        //构建一个默认的编辑器
        var index = layedit.build('content');
        //自定义工具栏
        // var index = layedit.build('content', {
        //     tool: [
        //         'strong' //加粗
        //         ,'italic' //斜体
        //         ,'underline' //下划线
        //         ,'del' //删除线
        //
        //         ,'|' //分割线
        //
        //         ,'left' //左对齐
        //         ,'center' //居中对齐
        //         ,'right' //右对齐
        //         ,'link' //超链接
        //         ,'unlink' //清除链接
        //         ,'face' //表情
        //         ,'image' //插入图片
        //         ,'help' //帮助
        //     ]
        //     ,height: 100
        // })
        //编辑器外部操;
        var active = {
            content: function(){
                //alert(layedit.getContent(index)); //获取编辑器内容
                layedit.sync(index);
            }
            ,text: function(){
                alert(layedit.getText(index)); //获取编辑器纯文本内容
            }
            ,selection: function(){           //获取选中内容
                alert(layedit.getSelection(index));
            }
        };

        $('.site-layedit').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


    });
</script>
</body>
</html>